/*
 * @Author: ChunLai
 * @Date: 2022-11-29 17:16:03
 * @LastEditTime: 2023-12-22 13:40:36
 * @Description: 其他信息校验规则(保单+险种) --- 待使用
 * @FilePath: \01.latest-short-insure\src\translate\validate\index.js
 */
import { getDataFromUrl } from "@/utils/index";

export const validRisksInfo = (risksInfo, totalPrem) => {
  // console.log("validRisksInfo", risksInfo)
  const proCompName = getDataFromUrl("company"),
    mainRisk = risksInfo[0],
    riskLen = risksInfo.length;
  let premCheck = true, // 保费校验标识
    proName = "",
    obj = {
      msg: "",
      status: true,
    };
  for (var i = 0; i < riskLen; i++) {
    const item = risksInfo[i];
    if (item.prem <= 0) {
      premCheck = false;
      proName = item.productName;
      break;
    }
  }
  // 保费不能为0校验
  if (!premCheck) {
    obj.msg = `'${proName}'险种不符合投保规则,请确认`;
    obj.status = false;
    return obj;
  }

  return obj;
};
